<template>
  <formPage ref="formPageRef" :formList="formData" validCatch="更多信息有未填写的数据！" identifying="tab3" />
</template>
<script setup>
const props = defineProps({
  topTable: {
    type: Array,
    default: [],
  },
  bottomTable: {
    type: Array,
    default: [],
  },
});
let formPageRef = ref(null);
const formData = computed(() => {
  let topArr = props.topTable
    .filter((item) => {
      return item.is_base !== 1 && item.in_form == 1;
    })
    .map((ele) => {
      let obj = {
        label: ele.name,
        prop: ele.field,
        formType: ele.form_type,
        required: ele.is_null == 1 ? true : false,
        rulesMessage: ele.input_tips || ele.name,
        placeholder: ele.input_tips || ele.name,
        termList: ele.termList,
      };
      if (ele.default_value) {
        obj.default_value = ele.default_value;
      }
      return obj;
    });

  let bottomArr = props.bottomTable.map((ele) => {
    let obj = {
      label: ele.name,
      prop: ele.field,
      formType: ele.form_type,
      required: ele.is_null == 1 ? true : false,
      rulesMessage: ele.input_tips || ele.name,
      placeholder: ele.input_tips || ele.name,
      termList: ele.termList,
    };
    return obj;
  });

  let allArr = topArr.concat(bottomArr);

  return allArr;
});
function updateFun(row) {
  formPageRef.value.updateFun(row);
}
onMounted(() => { });
function initFun() {
  formPageRef.value.initFun();
}
defineExpose({
  initFun,
  updateFun,
});
</script>
<style scoped lang="scss">
.ruleform-tab {
  :deep(.el-form-item) {
    width: 100%;
    margin-right: 0;
    padding-right: 10px;
    box-sizing: border-box;

    .el-input {
      width: 100%;
    }
  }
}
</style>
